package cn.village.service.impl;
import cn.village.dao.CompensationContractMapper;
import cn.village.entity.CompensationContract;
import cn.village.service.CompensationContractService;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class CompensationContractServiceImpl implements CompensationContractService {

    @Resource
    private CompensationContractMapper compensationContractMapper;

    public CompensationContract getCompensationContractById(String id)throws Exception{
        return compensationContractMapper.getCompensationContractById(id);
    }

    public List<CompensationContract>	getCompensationContractListByMap(Map<String,Object> param)throws Exception{
        return compensationContractMapper.getCompensationContractListByMap(param);
    }

    public Integer getCompensationContractCountByMap(Map<String,Object> param)throws Exception{
        return compensationContractMapper.getCompensationContractCountByMap(param);
    }

    public Integer qdtxAddCompensationContract(CompensationContract compensationContract)throws Exception{
            //compensationContract.setCreatedTime(new Date());
            return compensationContractMapper.insertCompensationContract(compensationContract);
    }

    public Integer qdtxModifyCompensationContract(CompensationContract compensationContract)throws Exception{
        //compensationContract.setUpdatedTime(new Date());
        return compensationContractMapper.updateCompensationContract(compensationContract);
    }

    public Integer qdtxDeleteCompensationContractById(String id)throws Exception{
        return compensationContractMapper.deleteCompensationContractById(id);
    }

    public Integer qdtxBatchDeleteCompensationContract(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return compensationContractMapper.batchDeleteCompensationContract(param);
    }


}
